
const initState = () => {
  return {
    headerForm: {},
    headerData: [],
    projectForm: {},
    projectData: [],
  }
}
const state = initState()

const mutations = {
  set_headerForm(state, headerForm) {
    state.headerForm = headerForm;
  },
  set_headerData(state, headerData) {
    state.headerData = headerData;
  },
  set_projectForm(state, projectForm) {
    state.projectForm = projectForm;
  },
  set_projectData(state, projectData) {
    state.projectData = projectData;
  },
}

const actions = {
  setHeaderForm({ commit }, headerForm) {
    commit('set_headerForm', headerForm)
  },
  setHeaderData({ commit }, headerData) {
    let data = [];
    (headerData || []).map(it => {
      data = data.concat(it.headerList);
    })
    commit('set_headerData', data);
  },
  setProjectForm({ commit }, projectForm) {
    commit('set_projectForm', projectForm)
  },
  setProjectData({ commit }, projectData) {
    commit('set_projectData', projectData)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
